# 7-2 反素数【函数】

def RPN():
    def is_prime(num):
        if num < 2:
            return False
        for i in range(2, int(num ** 0.5) + 1):
            if num % i == 0:
                return False
        return True
    def reverse_num(num):
        return int(str(num)[::-1])

    def find_reverse_primes(n):
        def is_reverse_prime(num):
            return is_prime(num) and is_prime(reverse_num(num)) and num != reverse_num(num)

        result = []
        num = 2
        while len(result) < n:
            if is_reverse_prime(num):
                result.append(num)
            num += 1
        return result
    n = int(input())
    reverse_primes = find_reverse_primes(n)
    for num in reverse_primes:
        print(num, end=' ')

RPN()